import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';

class LoadingWidget extends StatelessWidget {
  final String text;

  LoadingWidget({Key key, this.text = '加载中'}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.transparent,
      body: Center(
        child: Container(
          height: 90,
          width: 90,
          decoration: BoxDecoration(
            color: Color.fromRGBO(0, 0, 0, 0.7),
            borderRadius: BorderRadius.circular(5),
          ),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [spinWidget(context), textWidget()],
          ),
        ),
      ),
    );
  }

  Widget spinWidget(BuildContext context) {
    return SpinKitRing(
      size: 32,
      lineWidth: 3,
      color: Theme.of(context).primaryColor,
    );
  }

  Widget textWidget() {
    return Padding(
      padding: EdgeInsets.only(top: 5),
      child: Text(
        text,
        style: TextStyle(
          color: Colors.white,
          fontSize: 13,
        ),
      ),
    );
  }
}
